//
//  NSDictionary+Y2Json.m
//  Pods-Y2Common_Example
//
//  Created by Mac on 2021/5/31.
//

#import "NSDictionary+Y2Json.h"

@implementation NSDictionary (Y2Json)

- (NSString *) y2JsonToString{
    NSString *string = [[NSString alloc] initWithData:[self jsonToData] encoding:NSUTF8StringEncoding];
    return string;
}

- (NSData *) y2JsonToData{
    @try {
        NSData *data = [NSJSONSerialization dataWithJSONObject:self options:0 error:nil];
        return data;
    } @catch (NSException *exception) {
        NSLog(@"%@", exception.reason);
        return [NSData data];
    }
}

@end
